/*
 * Copyright (c) 2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_HOST_IMPL_H
#define FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_HOST_IMPL_H

#include "bundle_resource_host.h"

namespace OHOS {
namespace AppExecFwk {
class BundleResourceHostImpl : public BundleResourceHost {
public:
    BundleResourceHostImpl() = default;
    virtual ~BundleResourceHostImpl() = default;

    virtual ErrCode GetBundleResourceInfo(const std::string &bundleName, const uint32_t flags,
        BundleResourceInfo &bundleResourceInfo, const int32_t appIndex = 0) override;

    virtual ErrCode GetLauncherAbilityResourceInfo(const std::string &bundleName, const uint32_t flags,
        std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfo, const int32_t appIndex = 0) override;

    virtual ErrCode GetAllBundleResourceInfo(const uint32_t flags,
        std::vector<BundleResourceInfo> &bundleResourceInfos) override;

    virtual ErrCode GetAllLauncherAbilityResourceInfo(const uint32_t flags,
        std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfos) override;

    virtual ErrCode AddResourceInfoByBundleName(const std::string &bundleName, const int32_t userId) override;

    virtual ErrCode AddResourceInfoByAbility(const std::string &bundleName, const std::string &moduleName,
        const std::string &abilityName, const int32_t userId) override;

    virtual ErrCode DeleteResourceInfo(const std::string &key) override;

    virtual ErrCode GetExtensionAbilityResourceInfo(const std::string &bundleName,
        const ExtensionAbilityType extensionAbilityType, const uint32_t flags,
        std::vector<LauncherAbilityResourceInfo> &extensionAbilityResourceInfo, const int32_t appIndex = 0) override;

    virtual ErrCode GetAllUninstallBundleResourceInfo(const int32_t userId, const uint32_t flags,
        std::vector<BundleResourceInfo> &bundleResourceInfos) override;

private:
    ErrCode CheckBundleNameValid(const std::string &bundleName, int32_t appIndex);
    ErrCode CheckExtensionAbilityValid(const std::string &bundleName, const ExtensionAbilityType extensionAbilityType,
        const uint32_t flags, int32_t appIndex);
};
} // AppExecFwk
} // OHOS
#endif // FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_HOST_IMPL_H
